package cn.king.springframework.beans.factory.support;

import cn.king.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:TODO
 * @Author:wangkun
 * @ClassName:DefaultSingletonBeanRegistry
 * @Package:cn.king.springframework.beans.factory.support
 * @Date:2022年04月09日 21:57
 * @Version:1.0
 * @Project:simple-spring
 */

/**
 *单例注册表的默认实现,利用map结构维护
 * beanname-bean结构
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private Map<String, Object> singletonObjects = new HashMap<>();


    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    /**
    * @author:wangkun
    * @param:
    * @return:
    * @exception:
    * @date:2022/4/9 21:59
    * @description:注册
    */
    public void addSingleton(String beanName,Object object){
        singletonObjects.put(beanName,object);
    }
}
